home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / RTLWIN16.PAK / CUSTCNTL.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  10KB  |  312 lines

  1. /*****************************************************************************\
  2. *                                                                             *
  3. * custcntl.h -  Custom Control Library header file                            *
  4. *                                                                             *
  5. \*****************************************************************************/
  6.  
  7. /* $Copyright: 1994$ */
  8.  
  9. #ifndef __CUSTCNTL_H    /* prevent multiple includes */
  10. #define __CUSTCNTL_H
  11.  
  12. #ifndef __WINDOWS_H
  13. #include <windows.h>    /* <windows.h> must be included */
  14. #endif  /* __WINDOWS_H */
  15.  
  16. #ifndef RC_INVOKED
  17. #pragma pack(push, 1)   /* Assume byte packing throughout */
  18. #endif /* RC_INVOKED */
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {            /* Assume C declarations for C++ */
  22. #endif  /* __cplusplus */
  23.  
  24. /* If included with the 3.0 windows.h, define compatible aliases */
  25. #if !defined(WINVER) || (WINVER < 0x030a)
  26. #define WINAPI      FAR PASCAL
  27. #define CALLBACK    FAR PASCAL
  28. #define LPCSTR      LPSTR
  29. #define UINT        WORD
  30. #define LPARAM      LONG
  31. #define WPARAM      WORD
  32. #define LRESULT     LONG
  33. #define HMODULE     HANDLE
  34. #define HINSTANCE   HANDLE
  35. #define HLOCAL      HANDLE
  36. #define HGLOBAL     HANDLE
  37. #endif  /* WIN3.0 */
  38.  
  39. /*
  40.  * Every custom control DLL must have three functions present,
  41.  * and they must be exported by the following ordinals.
  42.  */
  43. #define CCINFOORD       2       /* information function ordinal */
  44. #define CCSTYLEORD      3       /* styles function ordinal */
  45. #define CCFLAGSORD      4       /* translate flags function ordinal */
  46.  
  47. /* general size definitions */
  48. #define CTLTYPES        12      /* max number of control types */
  49. #define CTLDESCR        22      /* max size of description */
  50. #define CTLCLASS        20      /* max size of class name */
  51. #define CTLTITLE        94      /* max size of control text */
  52.  
  53. /*
  54.  * CONTROL STYLE DATA STRUCTURE
  55.  *
  56.  * This data structure is used by the class style dialog function
  57.  * to set and/or reset various control attributes.
  58.  *
  59.  */
  60. typedef struct tagCTLSTYLE
  61. {
  62.     UINT    wX;                 /* x origin of control */
  63.     UINT    wY;                 /* y origin of control */
  64.     UINT    wCx;                /* width of control */
  65.     UINT    wCy;                /* height of control */
  66.     UINT    wId;                /* control child id */
  67.     DWORD   dwStyle;            /* control style */
  68.     char    szClass[CTLCLASS];  /* name of control class */
  69.     char    szTitle[CTLTITLE];  /* control text */
  70. } CTLSTYLE;
  71. typedef CTLSTYLE *      PCTLSTYLE;
  72. typedef CTLSTYLE FAR*   LPCTLSTYLE;
  73.  
  74. /*
  75.  * CONTROL DATA STRUCTURE
  76.  *
  77.  * This data structure is returned by the control options function
  78.  * when inquiring about the capabilities of a particular control.
  79.  * Each control may contain various types (with predefined style
  80.  * bits) under one general class.
  81.  *
  82.  * The width and height fields are used to provide the host
  83.  * application with a suggested size.  The values in these fields
  84.  * are in rc coordinates.
  85.  *
  86.  */
  87. typedef struct tagCTLTYPE
  88. {
  89.     UINT    wType;              /* type style */
  90.     UINT    wWidth;             /* suggested width */
  91.     UINT    wHeight;            /* suggested height */
  92.     DWORD   dwStyle;            /* default style */
  93.     char    szDescr[CTLDESCR];  /* description */
  94. } CTLTYPE;
  95.  
  96. typedef struct tagCTLINFO
  97. {
  98.     UINT    wVersion;           /* control version */
  99.     UINT    wCtlTypes;          /* control types */
  100.     char    szClass[CTLCLASS];  /* control class name */
  101.     char    szTitle[CTLTITLE];  /* control title */
  102.     char    szReserved[10];     /* reserved for future use */
  103.     CTLTYPE Type[CTLTYPES];     /* control type list */
  104. } CTLINFO;
  105. typedef CTLINFO *       PCTLINFO;
  106. typedef CTLINFO FAR*    LPCTLINFO;
  107.  
  108. /* These two function prototypes are used by the dialog editor */
  109. #ifdef STRICT
  110. typedef DWORD   (CALLBACK* LPFNSTRTOID)(LPCSTR);
  111. #else
  112. typedef DWORD   (CALLBACK* LPFNSTRTOID)(LPSTR);
  113. #endif
  114. typedef UINT    (CALLBACK* LPFNIDTOSTR)(UINT, LPSTR, UINT);
  115.  
  116. /* function  prototypes left out of the original custcntl.h */
  117.  
  118. typedef HGLOBAL (CALLBACK *LPFNINFO)( void );
  119. typedef BOOL            (CALLBACK *LPFNSTYLE)
  120. (
  121.   HWND    hWnd,
  122.   HGLOBAL hCntlStyle,
  123.   LPFNSTRTOID lpfnSID,
  124.   LPFNIDTOSTR lpfnIDS
  125. );
  126.  
  127. typedef UINT   (CALLBACK *LPFNFLAGS)
  128. (
  129.   DWORD   dwStyle,
  130.   LPSTR   lpBuff,
  131.   UINT    wBuffLength
  132. );
  133.  
  134. /*****************************************************************************
  135.  
  136.   Resource Workshop has extended the MS Dialog editor's custom control
  137.   API in three main areas:
  138.  
  139.   1) More than 1 custom control can be placed in a single DLL
  140.  
  141.   2) The "Info" data structure has been extended to allow custom controls
  142.      to be added to the RW toolbox
  143.  
  144.   3) The style data structure has been extended to allow custom controls
  145.      access to the CTLDATA field. This field contains up to 255 bytes
  146.      of binary data. A pointer to this data is passed to the control
  147.      in the WM_CREATE message at runtime.
  148.  
  149.  
  150. *****************************************************************************/
  151.  
  152. /*****************************************************************************
  153.  
  154.   Two new fields have been added to the CTLTYPE data structure to
  155.   make the RWCTLTYPE structure:
  156.  
  157.   hToolBit is a handle to a 24X24 bitmap which is added to the
  158.   RW toolbox. If this field is 0, no button will be added for this style,
  159.   and it will only be selectable via the Custom control dialog. This bitmap
  160.   is "owned" by RW, and will be freed by RW when the dialog editor is
  161.   unloaded.
  162.  
  163.   hDropCurs is a handle to a cursor which is used by RW when a user
  164.   selects the control from the toolbox. If 0, a cross cursor will be used.
  165.  
  166.  
  167. *****************************************************************************/
  168.  
  169. #define TOOLBIT_SIZE  24
  170.  
  171. typedef struct
  172. {
  173.    UINT       wType;                  /* type style */
  174.    UINT       wWidth;                 /* suggested width */
  175.    UINT       wHeight;                /* suggested height */
  176.    DWORD      dwStyle;                /* default style */
  177.    char       szDescr[CTLDESCR];      /* dialog name */
  178.    HBITMAP    hToolBit;               // Toolbox bitmap
  179.    HCURSOR    hDropCurs;              // Drag and drop cursor
  180.  
  181. } RWCTLTYPE, FAR * LPRWCTLTYPE;
  182.  
  183. /*****************************************************************************
  184.  
  185.   This structure reflects the RWCTLTYPE data structure
  186.  
  187. *****************************************************************************/
  188.  
  189.  
  190. typedef struct
  191. {
  192.    UINT       wVersion;              /* control version */
  193.    UINT       wCtlTypes;             /* control types */
  194.    char       szClass[CTLCLASS];     /* control class name */
  195.    char       szTitle[CTLTITLE];     /* control title */
  196.    char       szReserved[10];        /* reserved for future use */
  197.    RWCTLTYPE  Type[CTLTYPES];        /* Resource Workshop control type list */
  198.  
  199. } RWCTLINFO;
  200.  
  201. typedef RWCTLINFO *             PRWCTLINFO;
  202. typedef RWCTLINFO FAR *         LPRWCTLINFO;
  203.  
  204. /*****************************************************************************
  205.  
  206.   Two new fields have been added to the CTLSTYLE data structure to make
  207.   the RWCTLSTYLE data structure:
  208.  
  209.   CtlDataSize is the size of
  210.   CtlData, which is an array of bytes passed to the control in the
  211.   WM_CREATE message.
  212.  
  213.  
  214. *****************************************************************************/
  215.  
  216. #define CTLDATALENGTH 255            // 255 bytes + Length Byte
  217.  
  218. typedef struct {
  219.   UINT    wX;                       /* x origin of control */
  220.   UINT    wY;                       /* y origin of control */
  221.   UINT    wCx;                      /* width of control */
  222.   UINT    wCy;                      /* height of control */
  223.   UINT    wId;                      /* control child id */
  224.   DWORD   dwStyle;                            /* control style */
  225.   char    szClass[CTLCLASS];        /* name of control class */
  226.   char    szTitle[CTLTITLE];        /* control text */
  227.   BYTE    CtlDataSize;              // Control data Size
  228.   BYTE    CtlData[ CTLDATALENGTH];  // Control data
  229.  
  230. } RWCTLSTYLE;
  231.  
  232. typedef RWCTLSTYLE *              PRWCTLSTYLE;
  233. typedef RWCTLSTYLE FAR *          LPRWCTLSTYLE;
  234.  
  235. /*****************************************************************************
  236.  
  237.   In order to use RW's extensions to the custom controls, a custom
  238.   control DLL *must* implement the ListClasses function. This function
  239.   returns a global memory handle to an initialized CTLCLASSLIST data
  240.   structure. All function pointers *must* point to valid functions.
  241.  
  242.  
  243. *****************************************************************************/
  244.  
  245. typedef struct
  246. {
  247.   LPFNINFO  fnRWInfo;           // RW Info function
  248.   LPFNSTYLE fnRWStyle;          // RW Style function
  249.   LPFNFLAGS fnFlags;            // Flags function
  250.   char  szClass[ CTLCLASS];
  251.  
  252. } RWCTLCLASS, FAR *LPRWCTLCLASS;
  253.  
  254. typedef struct
  255. {
  256.   short       nClasses;
  257. #if defined (__cplusplus)
  258.   RWCTLCLASS Classes[1];
  259. #else
  260.   RWCTLCLASS Classes[];
  261. #endif
  262.  
  263. } CTLCLASSLIST, FAR *LPCTLCLASSLIST;
  264.  
  265. #ifdef STRICT
  266. typedef HGLOBAL   (CALLBACK *LPFNLOADRES)( LPCSTR szType, LPCSTR szId);
  267. typedef BOOL      (CALLBACK *LPFNEDITRES)( LPCSTR szType, LPCSTR szId);
  268. #else
  269. typedef HGLOBAL   (CALLBACK *LPFNLOADRES)( LPSTR szType, LPSTR szId);
  270. typedef BOOL      (CALLBACK *LPFNEDITRES)( LPSTR szType, LPSTR szId);
  271. #endif
  272.  
  273. #ifdef STRICT
  274. typedef HGLOBAL (CALLBACK *LPFNLIST)
  275. (
  276.   LPSTR       szAppName,
  277.   UINT        wVersion,
  278.   LPFNLOADRES fnLoad,
  279.   LPFNEDITRES fnEdit
  280. );
  281. #else
  282. typedef HGLOBAL (CALLBACK *LPFNLIST)
  283. (
  284.   LPCSTR      szAppName,
  285.   UINT        wVersion,
  286.   LPFNLOADRES fnLoad,
  287.   LPFNEDITRES fnEdit
  288. );
  289. #endif
  290.  
  291. #define DLGCUSTCLASSNAME   "_BorDlg_DlgEditChild"
  292. #define DLGTESTCLASSNAME   "_BorDlg_DlgEditTest"
  293.  
  294.  
  295. // Rw version 1.02 and above send a message to a control
  296. // when the user is about to delete it. The message id
  297. // is that returned by RegisterWindowMessage, with the following
  298. // name:
  299.  
  300. #define RWDELETEMSGNAME "Rws_deletecontrol"
  301.  
  302.  
  303. #ifdef __cplusplus
  304. }
  305. #endif  /* __cplusplus */
  306.  
  307. #ifndef RC_INVOKED
  308. #pragma pack(pop)       /* Revert to default packing */
  309. #endif  /* RC_INVOKED */
  310.  
  311. #endif  /* __CUSTCNTL_H */
  312.